Source Code Viewer - Example 7 - ArithmeticForm

package name.matthewgreet.example7.form;

import java.io.Serializable;

import com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;

public class ArithmeticForm implements Serializable {
	private static final long serialVersionUID = -5287580238710655353L;
	
	private int operand1;
	private String operator;
	private Integer operand2;
	
	@ConversionErrorFieldValidator(message = "Operand 1 must be a number!", repopulateField = true, shortCircuit = true)
	@RequiredFieldValidator(message = "Operand 1 is required")
    public int getOperand1() {
		return operand1;
	}
	public void setOperand1(int operand1) {
		this.operand1 = operand1;
	}

	@RequiredStringValidator(message = "Operator is required")
	public String getOperator() {
		return operator;
	}
	public void setOperator(String operator) {
		this.operator = operator;
	}

	@ConversionErrorFieldValidator(message = "Operand 2 must be a number!", repopulateField = true, shortCircuit = true)
	@RequiredFieldValidator(message = "Operand 2 is required")
	public Integer getOperand2() {
		return operand2;
	}
	public void setOperand2(Integer operand2) {
		this.operand2 = operand2;
	}
	
	
	
	@Override
	public String toString() {
		return "ArithmeticForm [operand1=" + operand1 + ", operator=" + operator + ", operand2=" + operand2 + "]";
	}

}